<script type="text/javascript" src="../media/system/js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="../media/system/js/jQuery.vietvang.validate.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$('#frm').validate({
			});
		});
</script>

<form action="index.php?option=com_pgb" method="post" name="adminForm" id="adminForm">
	<?php
     //check user group
           $aut=new bgAuthorize();
          // check  user login
           $group=$aut->getUserGroup();
           $u=JFactory::getUser();
           $u_ocba= $u->USEM_OCBA_CODE;
           if($group!=11)
           {
        ?>
    <fieldset id="filter-bar">
        
		<div class="filter-search fltlft" style="width: 100%;">
			<label class="filter-search-lbl" for="filter_search" style="line-height: 20px;font-size: 13px;">フィルタ&nbsp;</label>
			<input type="text" name="filter_search" id="filter_search" value="<?php echo JRequest::getVar('filter_search') ?>" title="センター名による検索" />

			<button type="submit" class="btn">検索</button>
			<button type="button" onclick="document.id('filter_search').value='';this.form.submit('search');">クリア</button>
            	
		</div>
        
		
	</fieldset>
	<div class="clr"> </div>
    <?php } ?>
	<table class="adminlist">
		<thead>
			<tr>
				<th width="5%" class="center">
                <input type="checkbox" name="checkall-toggle" value="" title="Check All" onclick="Joomla.checkAll(this)">					
				</th>
				<th width="25%" class="left">
					<label class="labelth">センター名</label>				
                </th>
				<th width="20%" class="center">
					<label class="labelth">プール種別</label>			
                </th>
				<th width="20%" class="center">
					<label class="labelth">体育館種別</label>				
                </th>
				<th width="20%" class="center">
					<label class="labelth">艇庫種別</label>		
                </th>
                <th width="10%" class="center">
					<label class="labelth">公開済/一時保存中</label>		
                </th>				
			</tr>
		</thead>
		<tfoot>
			<tr>
				<td colspan="15">
				    <?php echo $this->pagination->getListFooter(); ?>	
                </td>
			</tr>
		</tfoot>
		<tbody>
            <?php foreach($this->rows as $k=>$row):?>
              <tr class="row<?php echo $k%2?>">
                    <td class="center">
                        <input type="checkbox" id="cb<?php echo $row->OCBA_CODE ?>" name="cid[]" value="<?php echo $row->OCBA_CODE ?>" onclick="Joomla.isChecked(this.checked);" />
                    </td>
                    <td><a href="javascript:void(0);" onclick="document.id('cb<?php echo $row->OCBA_CODE; ?>').checked=true;Joomla.submitbutton('edit');" ><?php echo $row->OCBA_NAME ?></a></td>
                    <td class="center"> 
                        <?php 
                            foreach($this->pooltype as $key=>$value){
                                if($row->POOL_POLK == $key){
                                    echo $value;
                                }
                                elseif(empty($row->POOL_CODE)){
                                    echo 'なし';
                                    break;
                                }
                                elseif(empty($row->POOL_POLK)){
                                    echo '未入力';
                                    break;
                                }
                            }
                        ?>
                    </td>
                    
                    <td class="center">
                        <?php
                        $model = $this->getModel();
                        $this->gymt = $model->getGYMT($row->OCBA_CODE);
                        $i=0;
                            foreach ($this->gymt as $value) {
                                foreach($this->gymtype as $key=>$v){
                                    if($value->GYMT_2NDK == $key){
                                        $i++;
                                        if($i == 1){
                                            echo $v;
                                        }
                                        else{
                                            echo ",".$v;
                                        }
                                    }
                                }
                            }
                            if(empty($row->GYMT_CODE)){
                                echo 'なし';
                            }
                        ?>
                    </td>
                    
                    <td class="center">
                        <?php
                            foreach($this->boattype as $value){
                                if($row->DOCK_DOCM_CODE == $value->DOCM_CODE){
                                    echo($value->DOCM_NAME);
                                }
                                elseif(empty($row->DOCK_CODE))
                                {
                                    echo'なし';
                                    break;
                                }
                                elseif(empty($row->DOCK_DOCM_CODE)){
                                    echo '未入力';
                                    break;
                                }
                            }
                        ?>
                    </td>
                    <td class="center">
                        <?php
                            if($row->POOL_WEBF == 1 || $row->GYMT_WEBF == 1 || $row->DOCK_WEBF == 1){
                                echo "公開済";
                            }else{
                                echo "一時保存中";
                            }
                        ?>
                    </td>
		      </tr>
          <?php endforeach ?>
		      
            
		</tbody>
	</table>

		

	<div>
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="boxchecked" value="0" />	
  </div>
</form>
<script>
Joomla.submitbutton = function(task){
	   if(task == 'remove'){
	       if(!confirm('選択したデータを削除します。よろしいですか？')){
	           return false;
	       }
	   }
       
       Joomla.submitform(task, document.getElementById('adminForm'));
       
 }
</script>